/*
package com.lemonfish.config;

import com.lemonfish.pojo.entity.User;
import com.lemonfish.service.UserService;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;

*/
/**
 * @author Masics 张超
 * @date 2020/2/28 21:41
 *//*

public class UserRealm extends AuthorizingRealm {
    @Autowired
    UserService userService;


    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
        System.out.println("执行授权");

        SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
        info.addStringPermission("user:add");

        return null;
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        System.out.println("进行认证");

        UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;
        User user = userService.checkUserByName(token.getUsername());
        System.out.println(user);
        // 如果user ==null 说明 不为空
        if (user == null) {
            return null;
        }


        return new SimpleAuthenticationInfo("", user.getPassword(), "");
    }
}
*/
